package remote_work.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import remote_work.util.MyClassLoader;

/**
 * @author LiuPing
 *
 * 2018年3月13日
 */
public class MyServer {

	private static ServerSocket serverSocket;
	
	public static void main(String[] args) {
		
		startServer();
	}
	
	private static void startServer() {
		try {
			MyClassLoader cl = new MyClassLoader();
			cl.loadClasses();
			serverSocket = new ServerSocket(8080);
			System.out.println("服务器启动成功...");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		while (true) {
			try {
				Socket socket = serverSocket.accept();
				new TaskService(socket).run();
			} catch (IOException e) {
				e.printStackTrace();
			} 
		}
	}
}
